package com.linghu.springcloud.controller;


import com.linghu.springcloud.bean.Member;
import com.linghu.springcloud.bean.Result;

import com.linghu.springcloud.service.MemberService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author 令狐荣豪
 * @version 1.0
 */
@RestController
@Slf4j
public class MemberController {

    @Resource
    private MemberService memberService;

    @GetMapping("/member/get/{id}")
    public Result getMemberById(@PathVariable("id") Long id){
        Member member = memberService.queryMemberById(id);
        return Result.success(member,"member-service-provider-10002");
    }

    @PostMapping("/member/save")
    @ResponseBody
    public Result save(@RequestBody Member member){
        int save = memberService.save(member);
        if (save>0){
            return Result.success();
        }else {
            return Result.error("401","添加用户失败");
        }
    }


}
